home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / powerd / source / lib / chunky_lib.lha / Chunky / CopyChunkyField.ass < prev    next >
Encoding:
Text File  |  2000-08-05  |  1.8 KB  |  84 lines

  1. ; CopyChunkyField(a0:PTR TO chunky,d0,d1,a1:PTR TO chunky,d2,d3,d4,d5,a2:PTR TO UBYTE)
  2.  
  3.     machine    mc68020
  4.  
  5.     xdef    _CopyChunkyField
  6. _CopyChunkyField
  7.     movem.l    d2-d7/a2-a4,-(a7)
  8.  
  9. ; DESTINATION BOUNDS
  10.     tst.l    d0        ; left bound
  11.     bge.s    .leftdone
  12.     move.l    d0,d7            ; store left negative offset
  13.     neg.l    d7
  14.     cmp.l    d4,d7
  15.     bge.s    .finish            ; out of bounds
  16.     moveq    #0,d0            ; left position
  17.     add.l    d7,d2
  18.     sub.l    d7,d4            ; new width
  19. .leftdone
  20.     tst.l    d1        ; top bound
  21.     bge.s    .topdone
  22.     move.l    d1,d7            ; store top negative offset
  23.     neg.l    d7
  24.     cmp.l    d5,d7
  25.     bge.s    .finish            ; out of bounds
  26.     moveq    #0,d1            ; top position
  27.     add.l    d7,d3
  28.     sub.l    d7,d5            ; new height
  29. .topdone
  30.     cmp.l    (a0),d0        ; right bound
  31.     bgt.s    .finish
  32.     move.l    (a0),d7            ; store maximal width
  33.     sub.l    d0,d7            ; change width
  34.     cmp.l    d4,d7            ; check if we can fit
  35.     bgt.s    .rightdone        ; we can fit
  36.     move.l    d7,d4            ; new width, we can't fit
  37. .rightdone
  38.     cmp.l    (4,a0),d1        ; bottom bound
  39.     bgt.s    .finish
  40.     move.l    (4,a0),d7            ; store maximal width
  41.     sub.l    d1,d7            ; change width
  42.     cmp.l    d5,d7            ; check if we can fit
  43.     bgt.s    .bottomdone        ; we can fit
  44.     move.l    d7,d5            ; new width, we can't fit
  45. .bottomdone
  46.  
  47.     move.l    a2,a4
  48.  
  49.     move.l    (a0),d7        ; get dest width to d6
  50.     muls.l    d1,d7
  51.     add.l    d7,d0        ; now we have start position in dest buffer
  52.     move.l    (8,a0),a2
  53.     add.l    d0,a2
  54.     add.l    d0,a4        ; and start position in mask buffer
  55.  
  56.     move.l    (a1),d7
  57.     muls.l    d3,d7
  58.     add.l    d7,d2
  59.     move.l    (8,a1),a3
  60.     add.l    d2,a3        ; and start position in source buffer
  61.  
  62.     move.l    (a0),d2        ; get the d2 and d3 values
  63.     sub.l    d4,d2
  64.     move.l    (a1),d3
  65.     sub.l    d4,d3
  66.  
  67.     subq.l    #1,d4
  68.     subq.l    #1,d5
  69.     move.l    d4,d7        ; store width
  70. .loopy    move.l    d7,d4        ; restore width
  71. .loopx    move.b    (a4)+,d0        ; get mask bool
  72.     bne.s    .noskip
  73.     addq.l    #1,a3
  74.     addq.l    #1,a2
  75.     bra.s    .skip
  76. .noskip    move.b    (a3)+,(a2)+    ; copy pixel
  77. .skip    dbra.s    d4,.loopx
  78.     adda.l    d2,a2
  79.     adda.l    d2,a4
  80.     adda.l    d3,a3
  81.     dbra.s    d5,.loopy
  82. .finish    movem.l    (a7)+,d2-d7/a2-a4
  83.     rts
  84.